home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 3.8 KB | 131 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWTxtBuf.h
- // Release Version: $ 1.0d11 $
- // Modifed by MEB to support non-single-byte characters
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWTXTBUF_H
- #define FWTXTBUF_H
-
- #ifndef FWGRDEF_H
- #include "FWGrDef.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // CLASS FW_CPrivTextBuffer
- //========================================================================================
- // Internal class used by the graphic component to read text from strings or text readers
- // for text measurement/drawing.
- // Text is sliced up into lines (terminated by newLine character)
- // We try to avoid dynamic memory allocation as much as possible
-
- class FW_CPrivTextBuffer FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CPrivTextBuffer(const FW_CString* string);
- // Constructs a buffer using a string as a source.
- // No data copying occurs.
-
- FW_CPrivTextBuffer(FW_CTextReader* reader);
- // Constructs a buffer using a text reader as a source.
- // No data copying occurs if the first block read from the reader
- // is as large as the whole data structure;
- // otherwise, data is copied into a temporary contiguous buffer line by line.
-
- virtual ~ FW_CPrivTextBuffer();
-
- FW_ByteCount GetTotalLength() const;
- // returns the total length (in bytes) of the whole data structure
-
- FW_Boolean IsDone() const;
- // returns TRUE when there is nothing left to read
-
- void GetNextLine();
- // reads the next line from the buffer
-
- const FW_Byte* GetCurrentLine() const;
- // returns a pointer to the current contiguous line of text
-
- FW_ByteCount GetCurrentLineLength() const;
- // returns length of the current line, in bytes
-
- private:
- void ResetBuffer(FW_ByteCount size = 256);
- void AppendCharacterToBuffer(FW_Char c);
-
- FW_CPrivTextBuffer(const FW_CPrivTextBuffer& otherBuffer);
- FW_CPrivTextBuffer& operator=(const FW_CPrivTextBuffer& otherBuffer);
- // Copy constructor and assignment operator not valid for this class.
-
- private:
- const FW_CString* fString;
- FW_CTextReader* fReader;
-
- FW_Byte* fCurrentLine;
- FW_ByteCount fCurrentLineLength;
-
- FW_Boolean fIsDone; // are we there yet?
-
- // ----- the stuff below is used when we read a FW_CTextReader
-
- static FW_Byte gStaticBuffer[];
- static unsigned short gStaticBufferUseCount;
- // To save stack space, the static buffer is, well, static
- // however, this class needs to be re-entrant (for printing), so
- // we maintain a semaphore which tells us whether the buffer is in use
-
- FW_Byte* fDynamicBufferBase;
- FW_ByteCount fDynamicBufferSize;
- // if the static buffer is busy, or if it is too small, we allocate a
- // dynamic buffer
-
- FW_ByteCount fCurrentBufferSize;
- // the current size of the current buffer
-
- };
-
- //========================================================================================
- // Global Method PrivGetStringSegment
- //========================================================================================
-
- FW_Boolean PrivGetStringSegment(ODPlatformCanvas platformCanvas,
- const char* str,
- FW_ByteCount len,
- FW_BytePosition& segStart,
- FW_ByteCount& segLen,
- FW_PlatformCoordinate maxWidth,
- FW_PlatformCoordinate& actualWidth,
- FW_Boolean wordWrap,
- FW_Boolean wordBreak);
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-
-